<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Alarm extends Model
{
    protected $table = 'monitor_alarm';
    public $timestamps = true;
    protected $guarded = [];
    public function getCharge(){
        $charge = MonitorCharge::where('scene_id',$this->scene_id)->first();
        return [
            'name'=>$charge?$charge->name:'',
            'phone'=>$charge?$charge->phone:'',
            'manager_id'=>$charge?$charge->manager_id:''
        ];
    }
    public function getSceneArea(){
        $scene = Scene::find($this->scene_id);
        return ['scene'=>$scene->title,'area'=>$scene->area->title];
    }
}